﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    public class CommandNextInputResult : BaseResult<object>
    {
        public Dictionary<string, string> NextValues = new Dictionary<string, string>();
        public void addNextValue(string key, string value)
        {
            NextValues.Add(key, value);
        }


        public static CommandNextInputResult CreateFailInstance(string failMsg, int errorIndex = -1, string command = "")
        {
            CommandNextInputResult cpr = new CommandNextInputResult();
            cpr.Success = false;
            cpr.Code = BaseResultCode.CODE_ADD_FAILURE;
            if (errorIndex >= 0)
            {
                var space = "";
                for (int i = 0; i < errorIndex; i++) space += " ";
                cpr.Description = $"{command}\r\n{space}^\r\n% ";
            }
            cpr.Description += failMsg;
            return cpr;
        }
        public static CommandNextInputResult CreateSuccessInstance()
        {
            CommandNextInputResult cpr = new CommandNextInputResult();
            cpr.Success = true;
            cpr.Code = BaseResultCode.CODE_OK;
            return cpr;
        }
        public static CommandNextInputResult CreateSuccessInstance(string key, string value)
        {
            CommandNextInputResult cpr = new CommandNextInputResult();
            cpr.Success = true;
            cpr.Code = BaseResultCode.CODE_OK;
            cpr.NextValues.Add(key, value);
            return cpr;
        }
    }
}
